<html>
<head><meta charset="utf-8"><title>hybrid algorithm in rustc · t-compiler/wg-polonius · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/index.html">t-compiler/wg-polonius</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html">hybrid algorithm in rustc</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="160863682"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/160863682" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#160863682">(Mar 15 2019 at 10:44)</a>:</h4>
<p>Ok, so how does the versioning for polonius-engine work; the one with the Hybrid engine becomes 0.6.3? Also, should I do the version increment as part of the pull request or is there some other standard way of doing that? I realise I am asking for the mentoring instructions task early :)</p>



<a name="160863782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/160863782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#160863782">(Mar 15 2019 at 10:45)</a>:</h4>
<p>Also, is there any particular reason why we aren't using Criterion for benchmarking? It seems incredibly cool to me, and I really like the repeated benchmarks to ensure that the changes are statistically significant</p>



<a name="160863972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/160863972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#160863972">(Mar 15 2019 at 10:48)</a>:</h4>
<p>Can <em>I</em> even Cargo publish new versions? I assume one needs some sort of special powers for that?</p>



<a name="160872713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/160872713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#160872713">(Mar 15 2019 at 13:10)</a>:</h4>
<blockquote>
<p>Ok, so how does the versioning for polonius-engine work; the one with the Hybrid engine becomes 0.6.3? Also, should I do the version increment as part of the pull request or is there some other standard way of doing that? I realise I am asking for the mentoring instructions task early :)</p>
</blockquote>
<p>Yeah, I guess this would be 0.6.3 -- technically, I suppose, extending a public enum is a breaking change though so we could make it 0.70</p>



<a name="160872736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/160872736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#160872736">(Mar 15 2019 at 13:10)</a>:</h4>
<blockquote>
<p>Also, is there any particular reason why we aren't using Criterion for benchmarking? It seems incredibly cool to me, and I really like the repeated benchmarks to ensure that the changes are statistically significant</p>
</blockquote>
<p>not really, except that generated random data that is meaningful to polonius is non-trivial</p>



<a name="160872743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/160872743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#160872743">(Mar 15 2019 at 13:10)</a>:</h4>
<p>I'm not super familiar with criterion, so maybe I'm saying something confused</p>



<a name="160872778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/160872778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#160872778">(Mar 15 2019 at 13:11)</a>:</h4>
<p>In the datafrog repository I did setup some kind of testing at least that was using quickcheck or some variant thereof</p>



<a name="160872788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/160872788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#160872788">(Mar 15 2019 at 13:11)</a>:</h4>
<p>that might be a place we could do benchmarking too</p>



<a name="160884610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/160884610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#160884610">(Mar 15 2019 at 15:22)</a>:</h4>
<p>Ah, but Criterion is for benchmarking, not for generating test input, apparently it replaces the built-in benchmarking and does some sort of statistical analysis on repeat experiments</p>



<a name="160884705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/160884705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#160884705">(Mar 15 2019 at 15:23)</a>:</h4>
<p>I think it also has facilities for comparing changes in performance between versions somehow but I haven't at all looked into that</p>



<a name="160955496"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/160955496" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#160955496">(Mar 16 2019 at 15:23)</a>:</h4>
<blockquote>
<p>extending a public enum is a breaking change</p>
</blockquote>
<p>Sounds like you could add the hidden non-exhaustive enum variant to prevent another major version bump in the future</p>



<a name="161042850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/161042850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#161042850">(Mar 18 2019 at 09:41)</a>:</h4>
<blockquote>
<blockquote>
<p>add the hidden non-exhaustive enum variant to prevent another major version bump in the future</p>
</blockquote>
</blockquote>
<p>I am not sure what this means; do you mean to use two enums?</p>



<a name="161043199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/161043199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#161043199">(Mar 18 2019 at 09:47)</a>:</h4>
<p>Also, does anyone know what the next step is for this? I have made the changes to rustc that <span class="user-mention" data-user-id="116009">@nikomatsakis</span> suggested, but I don't know how to go about version-bumping Polonius (modulo the changes <span class="user-mention" data-user-id="116155">@Jake Goulding</span> suggested).</p>



<a name="161056748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/161056748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#161056748">(Mar 18 2019 at 13:26)</a>:</h4>
<p>Something like</p>
<div class="codehilite"><pre><span></span><span class="k">enum</span> <span class="nc">PoloniusAlgo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Slow</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">Fast</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">ReallyFast</span><span class="p">,</span><span class="w"></span>

<span class="w">    </span><span class="cp">#[doc(hidden)]</span><span class="w"></span>
<span class="w">    </span><span class="n">__NonExhaustive</span><span class="p">,</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>For more context, see <a href="https://rust-lang.github.io/rfcs/2008-non-exhaustive.html" target="_blank" title="https://rust-lang.github.io/rfcs/2008-non-exhaustive.html">RFC 2008</a></p>



<a name="161056949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/161056949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#161056949">(Mar 18 2019 at 13:29)</a>:</h4>
<p>TL;DR: by hiding one variant, it's hard (but not impossible) to match on all of the variants, forcing consumers to have a catch-all variant. Without that last variant, people could write</p>
<div class="codehilite"><pre><span></span><span class="k">match</span><span class="w"> </span><span class="n">algo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Slow</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">    </span><span class="n">Fast</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">    </span><span class="n">ReallyFast</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>And then adding a new variant would cause their code to fail to compile.</p>



<a name="161057239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/161057239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#161057239">(Mar 18 2019 at 13:32)</a>:</h4>
<p>instead, with the hidden variant, they are "forced" to write</p>
<div class="codehilite"><pre><span></span><span class="k">match</span><span class="w"> </span><span class="n">algo</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Slow</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">    </span><span class="n">Fast</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">    </span><span class="n">ReallyFast</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="w">    </span><span class="n">_</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>Then adding a new variant will fall into the last arm</p>



<a name="161057291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/161057291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#161057291">(Mar 18 2019 at 13:33)</a>:</h4>
<p>There's reasons that both are good — maybe you <em>do</em> want to force people to address the new variant when its added</p>



<a name="161057349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/161057349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jake Goulding <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#161057349">(Mar 18 2019 at 13:34)</a>:</h4>
<p>And bumping a semver-incompatible versions isn't really a big inconvenience.</p>



<a name="161057562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/161057562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#161057562">(Mar 18 2019 at 13:36)</a>:</h4>
<p>Ah, ok. I didn't know about hidden variants, thanks for explaining!</p>



<a name="161156660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/161156660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#161156660">(Mar 19 2019 at 14:44)</a>:</h4>
<p><span class="user-mention" data-user-id="204115">@Albin Stjerna</span> ok I've merged <a href="https://github.com/rust-lang-nursery/polonius/issues/102" target="_blank" title="https://github.com/rust-lang-nursery/polonius/issues/102">polonius#102</a> (your PR). The next steps for integrating into rustc would be the following:</p>
<p>1. First, we have to release a new version of polonius-engine<br>
  - typically, I do this by creating a PR that bumps the <code>version = "XXX"</code> numbers in the relevant Cargo.toml files -- maybe you want to create this PR?<br>
  - then I can run cargo publish<br>
2. Then, we have to open a PR against <em>rustc</em> that changes the Cargo.toml file to use this newer version and updates the source</p>



<a name="161163557"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/161163557" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#161163557">(Mar 19 2019 at 16:03)</a>:</h4>
<p>1. Done: <a href="https://github.com/rust-lang/polonius/pull/103" target="_blank" title="https://github.com/rust-lang/polonius/pull/103">https://github.com/rust-lang/polonius/pull/103</a><br>
2. Queued up and waiting for publish!</p>



<a name="161282418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/161282418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#161282418">(Mar 20 2019 at 19:24)</a>:</h4>
<p><span class="user-mention" data-user-id="204115">@Albin Stjerna</span> <a href="https://github.com/rust-lang/polonius/pull/103#pullrequestreview-216933775" target="_blank" title="https://github.com/rust-lang/polonius/pull/103#pullrequestreview-216933775">left a review here</a></p>



<a name="161284112"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/186049-t-compiler/wg-polonius/topic/hybrid%20algorithm%20in%20rustc/near/161284112" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanda Stjerna <a href="https://rust-lang.github.io/zulip_archive/stream/186049-t-compiler/wg-polonius/topic/hybrid.20algorithm.20in.20rustc.html#161284112">(Mar 20 2019 at 19:45)</a>:</h4>
<blockquote>
<p><span class="user-mention silent" data-user-id="204115">Albin Stjerna</span> <a href="https://github.com/rust-lang/polonius/pull/103#pullrequestreview-216933775" target="_blank" title="https://github.com/rust-lang/polonius/pull/103#pullrequestreview-216933775">left a review here</a></p>
</blockquote>
<p>Thanks, addressed and pushed!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>